home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume10 / gb3 / patch2f < prev    next >
Encoding:
Internet Message Format  |  1990-08-28  |  58.2 KB

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v11i044:  gb3 - Galactic Bloodshed, an empire-like war game [Ver. 2.0], Patch2f
  5. Message-ID: <6231@tekred.CNA.TEK.COM>
  6. Date: 28 Aug 90 19:36:00 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 2107
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: VANCLEEF@mps.ohio-state.edu
  12. Posting-number: Volume 11, Issue 44
  13. Archive-name: gb3/Patch2f
  14. Patch-To: gb3: Volume 10, Issue 1-14
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 6 (of 9)."
  25. # Contents:  Docs/mount.doc client/map.c server/dock.c server/doship.c
  26. #   server/name.c
  27. # Wrapped by billr@saab on Tue Aug 28 08:54:57 1990
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'Docs/mount.doc' -a "${1}" != "-c" ; then 
  30.   echo shar: Renaming existing file \"'Docs/mount.doc'\" to \"'Docs/mount.doc.orig'\"
  31.   mv -f 'Docs/mount.doc' 'Docs/mount.doc.orig'
  32. fi
  33. echo shar: Extracting \"'Docs/mount.doc'\" \(784 characters\)
  34. sed "s/^X//" >'Docs/mount.doc' <<'END_OF_FILE'
  35. XMOUNT            Galactic Bloodshed            MOUNT
  36. X
  37. X
  38. XNAME
  39. X  mount -- mount a crystal into a ship's hyper-drive.
  40. X  dismount -- dismount a crystal from the drive.
  41. X
  42. XSYNTAX
  43. X  mount
  44. X  dismount
  45. X
  46. XDESCRIPTION
  47. X  
  48. X   Normally, a ship requires a waiting period before a hyperspace
  49. Xjump can be executed. This requires powering up the drive for
  50. Xsome period of time. However, the charge-up time can been bypassed
  51. Xif a player has a crystal mounted. The effect of a crystal also
  52. Xallows the ship to jump farther and more fuel efficiently than
  53. Xfor a ship without a crystal mounted.
  54. X
  55. X   In order to mount a crystal, the player must change scope to the
  56. Xship which is to have a crystal mounted. The ship must have a
  57. Xcrystal on board. A crystal can be dismounted using the 'dismount'
  58. Xcommand.
  59. X
  60. XSEE ALSO
  61. X    crystal, order  
  62. X
  63. END_OF_FILE
  64. if test 784 -ne `wc -c <'Docs/mount.doc'`; then
  65.     echo shar: \"'Docs/mount.doc'\" unpacked with wrong size!
  66. fi
  67. # end of 'Docs/mount.doc'
  68. if test -f 'client/map.c' -a "${1}" != "-c" ; then 
  69.   echo shar: Renaming existing file \"'client/map.c'\" to \"'client/map.c.orig'\"
  70.   mv -f 'client/map.c' 'client/map.c.orig'
  71. fi
  72. echo shar: Extracting \"'client/map.c'\" \(4750 characters\)
  73. sed "s/^X//" >'client/map.c' <<'END_OF_FILE'
  74. X/*
  75. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  76. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  77. X * GB_copyright.h. 
  78. X *
  79. X *    map.c -- display sector map of current planet 
  80. X *
  81. X *    plot_surface():    Plot as much of the planet surface as possible.
  82. X *            If the planet surface is complete, return. Else
  83. X *            set MAP to FALSE, and wait for the next packet.
  84. X *
  85. X *    plot_balance():    Try to synchronize with the last character that
  86. X *            was output. Complete the current character, then
  87. X *            the current line, then the current map. Clear
  88. X *            MAP flag.
  89. X *    bugs: Not clean if the packets become screwy. plot_balance has
  90. X *    no way of recovering from errors. Starting the balance of the
  91. X *    map with the last character in a row or the last character in
  92. X *    the map might screw up everything. No testing for this case.
  93. X *
  94. X *    Version 1.1    25-Jul-90    Hubert Bartels
  95. X *                    hgb@catalina.opt-sci.arizona.edu
  96. X *                    Made modifications to complete
  97. X *                    maps.
  98. X */
  99. X
  100. X#include "GB_copyright.h"
  101. X#define S_X (stdscr->_maxx - NAMESIZE)
  102. X#define S_Y (stdscr->_maxy - 1)
  103. X#define Midx ((S_X - NAMESIZE)/2.0)
  104. X#define Midy (S_Y /2.0)
  105. X#define DISP_DATA 1
  106. X
  107. X#include <curses.h>
  108. X#include <stdio.h>
  109. X
  110. X/*
  111. X    Map completion code
  112. X*/
  113. X#define SHIFT_IN    0x10
  114. X#define SHIFT_OUT    0x20
  115. X
  116. Xextern int MAP;            /* True if in map mode */
  117. Xextern int s_in_out;        /* TRUE if this was to be a shiftin/out flag */
  118. X                /* if not TRUE, then SHIFT_OUT or SHIFT_IN */
  119. X                /* depending on the state of stand. */ 
  120. Xextern int curY;        /* The current Y ( row), location */
  121. Xextern int curX;        /* The current X ( col), location */
  122. Xextern int Maxx;        /* The maximum X size */
  123. Xextern int Maxy;        /* The maximum Y size */
  124. Xextern char    *index(), *malloc();
  125. Xextern int    have_inv;
  126. X
  127. Xplot_surface(t)
  128. Xchar *t;
  129. X{
  130. X    register int x, y;
  131. X    int stand, show;
  132. X    char *u, *v;
  133. X    extern int MAP;
  134. X    extern int s_in_out;
  135. X    extern int curX;
  136. X    extern int curY;
  137. X    extern int Maxx;
  138. X    extern int Maxy;
  139. X
  140. X    clear();
  141. X    u = t + 1;
  142. X    /* get planet name */
  143. X    v = index(u, ';');
  144. X    *v = 0;
  145. X    move(0, 9);
  146. X    printw("`%s'\n   ", u);
  147. X
  148. X    u = v + 1;
  149. X    v = index(u, ';');
  150. X    *v = 0;
  151. X    Maxx = atoi(u);
  152. X
  153. X    u = v + 1;
  154. X    v = index(u, ';');
  155. X    *v = 0;
  156. X    Maxy = atoi(u);
  157. X
  158. X    u = v + 1;
  159. X    v = index(u, ';');
  160. X    *v = 0;
  161. X    show = atoi(u);
  162. X    for (x = 0; x < Maxx; x++) printw("%d", x / 10);
  163. X    printw("\n   ");
  164. X    for (x = 0; x < Maxx; x++) printw("%d", x % 10);
  165. X    printw("\n");
  166. X    u = v + 1;
  167. X    for (y = 0; y < Maxy; y++) {
  168. X        curY = y;
  169. X        mvaddch(y + 3, 0, y / 10 + '0');
  170. X        addch(y % 10 + '0');
  171. X        for (x = 0; x < Maxx; x++) {
  172. X            curX = x;
  173. X            if( *u == '\0') {
  174. X                MAP = TRUE;
  175. X                s_in_out = TRUE;
  176. X                refresh();
  177. X                return;
  178. X            }
  179. X            if (*u++ == '0') stand = 0; else stand = 1;
  180. X            if( *u == '\0') {
  181. X                MAP = TRUE;
  182. X                if( stand == 0)
  183. X                    s_in_out = SHIFT_OUT;
  184. X                else
  185. X                    s_in_out = SHIFT_IN;
  186. X                refresh();
  187. X                return;
  188. X            }
  189. X            if (stand && have_inv) standout();
  190. X            mvaddch(y + 3, x + 3, *u);
  191. X            if (stand && have_inv) standend();
  192. X            u++;
  193. X        }
  194. X    }
  195. X    MAP = FALSE;
  196. X    curY = curX = 0;
  197. X    move(Maxy + 4, 0);
  198. X    refresh();
  199. X}
  200. X/*
  201. X    plot_balance tries to find out where the map was truncated,
  202. X    and tries to continue from the last location written.
  203. X
  204. X    Version 1.0    25-Jul-90    HGB, modified from plot_surface.
  205. X*/
  206. Xplot_balance(t)
  207. Xchar *t;
  208. X{
  209. X    register int x, y;
  210. X    int stand;
  211. X    char *u;
  212. X    extern int MAP;
  213. X    extern int s_in_out;
  214. X    extern int curY;
  215. X    extern int curX;
  216. X    extern int Maxx;
  217. X    extern int Maxy;
  218. X/*
  219. X    Check if we are supposed to be here.
  220. X*/
  221. X    if( MAP == FALSE) return;
  222. X/*
  223. X    Try to write the rest of the current row from the current buffer
  224. X    also, we need to synchronize. If the first character is 0/1, this
  225. X    is the standout/standin character. If the first character is not,
  226. X    output this character.
  227. X*/
  228. X    u = t;
  229. X    y = curY;
  230. X    x = curX;
  231. X/*
  232. X    Synchronize. SHIFT_IN means we saw the standout flag, but
  233. X    not the character. We draw the character, up the X counter,
  234. X    and enter the balance of items loop for this row.
  235. X*/    
  236. X    if( s_in_out == SHIFT_IN && have_inv ) standout();
  237. X    if( s_in_out != TRUE) {
  238. X        mvaddch(y + 3, x + 3, *u);
  239. X        if (s_in_out == SHIFT_IN && have_inv) standend();
  240. X        curX++;
  241. X    }
  242. X    refresh();
  243. X/*
  244. X    Now, draw the rest of the line.
  245. X*/
  246. X    for( x = curX; x < Maxx; x++) {
  247. X        if (*u == '0') stand = 0; else stand = 1;
  248. X        u++;
  249. X        if (stand && have_inv) standout();
  250. X        mvaddch(y + 3, x + 3, *u);
  251. X        if (stand && have_inv) standend();
  252. X        u++;
  253. X    }
  254. X    refresh();
  255. X    curY++;
  256. X/*
  257. X    Try to draw the balance of the map, now. We should be synchronized.
  258. X*/
  259. X    for (y = curY; y < Maxy; y++) {
  260. X        mvaddch(y + 3, 0, y / 10 + '0');
  261. X        addch(y % 10 + '0');
  262. X        for (x = 0; x < Maxx; x++) {
  263. X            if (*u == '0') stand = 0; else stand = 1;
  264. X            u++;
  265. X            if (stand && have_inv)
  266. X                standout();
  267. X            mvaddch(y + 3, x + 3, *u);
  268. X            if (stand && have_inv)
  269. X                standend();
  270. X            u++;
  271. X        }
  272. X        refresh();
  273. X    }
  274. X    MAP = FALSE;
  275. X    curX = curY = 0;
  276. X    move(Maxy + 4, 0);
  277. X    refresh();
  278. X    return;
  279. X}
  280. END_OF_FILE
  281. if test 4750 -ne `wc -c <'client/map.c'`; then
  282.     echo shar: \"'client/map.c'\" unpacked with wrong size!
  283. fi
  284. # end of 'client/map.c'
  285. if test -f 'server/dock.c' -a "${1}" != "-c" ; then 
  286.   echo shar: Renaming existing file \"'server/dock.c'\" to \"'server/dock.c.orig'\"
  287.   mv -f 'server/dock.c' 'server/dock.c.orig'
  288. fi
  289. echo shar: Extracting \"'server/dock.c'\" \(13087 characters\)
  290. sed "s/^X//" >'server/dock.c' <<'END_OF_FILE'
  291. X/*
  292. X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  293. X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  294. X** Restrictions in GB_copyright.h.
  295. X**
  296. X**  dock.c -- dock a ship
  297. X**  and..... assault -- a very un-PC version of dock
  298. X*/
  299. X
  300. X#include "GB_copyright.h"
  301. X#define EXTERN extern
  302. X#include "vars.h"
  303. X#include "ships.h"
  304. X#include "races.h"
  305. X#include "buffers.h"
  306. X#include <signal.h>
  307. X#include <math.h>
  308. X
  309. Xint dock_sectdata, dock_shdata, dock_pdata, dock_racedata;
  310. Xint dock_stdata;
  311. X
  312. Xdock(Playernum,APcount, argn,args, Assault)
  313. Xint Playernum;
  314. Xint APcount;
  315. Xint argn;
  316. Xchar args[MAXARGS][COMMANDSIZE];
  317. Xint Assault;    /* unfriendly dock */
  318. X{
  319. Xchar c;
  320. Xshiptype *s,*s2,*s3;
  321. Xplanettype *p;
  322. Xsectortype *sect;
  323. Xint boarders,oldspopn,olds2popn,dam,dam2,booby,
  324. X    numdest=0,ship2no,shipno,x= -1,y= -1,i,mask;
  325. Xint old2owner,sh, sh3;
  326. Xint casualties, casualties2, casualty_scale;
  327. Xfloat fuel,bstrength,b2strength,pris;
  328. Xdouble Dist;
  329. Xracetype *Race, *alien;
  330. X
  331. Xdock_sectdata = dock_shdata = dock_pdata = NEUTRAL_FD;
  332. X
  333. X
  334. X        sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
  335. X        sscanf(args[2]+(args[2][0]=='#'),"%d",&ship2no);
  336. X
  337. X
  338. X openshdata(&dock_shdata);
  339. X  if (!getship(dock_shdata, &s, shipno)) {
  340. X      notify(Playernum, "The ship wasn't found.\n");
  341. X    close_file(dock_shdata);
  342. X    return;
  343. X  }
  344. Xclose_file(dock_shdata);
  345. X  if (testship(Playernum,s, shipno)) {
  346. X      notify(Playernum, "Illegal format.\n");
  347. X      free(s);
  348. X      return;
  349. X    }
  350. X
  351. X    if(!Assault) {
  352. X          if (s->is_docked) {
  353. X            sprintf(buf,"Ship #%d is already docked.\n",shipno);
  354. X            notify(Playernum, buf);
  355. X            free(s);
  356. X            return;
  357. X              }
  358. X        } else if(s->is_docked) {
  359. X            if(s->whatdest==LEVEL_PLAN) {
  360. X                notify(Playernum, "Target ship is landed.\n");
  361. X                free(s);
  362. X                return;
  363. X            } else if(!(s->whatdest==LEVEL_SHIP)) {
  364. X                notify(Playernum, "Weird error..\n");
  365. X                free(s);
  366. X                return;
  367. X            }
  368. X        }
  369. X
  370. X  if (s->whatorbits==LEVEL_UNIV) {
  371. X         if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount)) {
  372. X         free(s);
  373. X         return;
  374. X        } 
  375. X     } else if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) { 
  376. X     free(s);
  377. X     return;
  378. X    }
  379. X
  380. X
  381. X    if(shipno==ship2no) {
  382. X        notify(Playernum, "You can't dock with yourself!\n");
  383. X        free(s);
  384. X        return;
  385. X    }
  386. X    
  387. X
  388. Xopenshdata(&dock_shdata);
  389. X  if (!getship(dock_shdata, &s2, ship2no)) {
  390. X      notify(Playernum, "The ship wasn't found.\n");
  391. X    close_file(dock_shdata);
  392. X    free(s);
  393. X    return;
  394. X  }
  395. Xclose_file(dock_shdata);
  396. X/*  if (testship(Playernum,s2, ship2no)) {
  397. X      notify(Playernum, "Illegal format.\n");
  398. X    free(s2);
  399. X          free(s);
  400. X          return;
  401. X    }
  402. X*/
  403. X    
  404. X  if (s2->is_docked) {
  405. X    sprintf(buf,"Ship #%d is already docked.\n",ship2no);
  406. X        notify(Playernum, buf);
  407. X    free(s);
  408. X    free(s2);
  409. X    return;
  410. X  }
  411. X
  412. X
  413. X        Dist = sqrt((double)Distsq(s2->xpos, s2->ypos, s->xpos, s->ypos ) );
  414. X        fuel = 0.05 + Dist * 0.025 * (Assault ? 2.0 : 1.0)*sqrt(s->mass);
  415. X
  416. X     if (Dist > DIST_TO_DOCK) {
  417. X         sprintf(buf,"Ship #%d must be %.2f or closer to ship #%d.\n",
  418. X            shipno, DIST_TO_DOCK, ship2no);
  419. X        notify(Playernum, buf);
  420. X         free(s);
  421. X         free(s2);
  422. X         return;
  423. X    } else if(s->is_docked && Assault) {
  424. X/* first undock the target ship */
  425. X        s->is_docked = 0;
  426. X        s->whatdest==LEVEL_UNIV;
  427. X        openshdata(&dock_shdata);
  428. X        (void)getship(dock_shdata, &s3, s->destshipno);
  429. X        s3->is_docked==0;
  430. X        s3->whatdest==LEVEL_UNIV;
  431. X        putship(dock_shdata, s3, s->destshipno);
  432. X        free(s3);
  433. X    }
  434. X
  435. X    if (fuel > s->fuel) {
  436. X        sprintf(buf,"Not enough fuel.\n");
  437. X            notify(Playernum, buf);
  438. X        free(s);
  439. X        free(s2);
  440. X        return;
  441. X    }
  442. X        sprintf(buf,"Distance to %s #%d: %.2f.\n", s2->name, ship2no, Dist);
  443. X        notify(Playernum, buf);
  444. X        sprintf(buf,"This maneuver will take %.2f fuel (of %.2f.)\n\n",fuel,s->fuel);
  445. X        notify(Playernum, buf);
  446. X
  447. X
  448. X
  449. X    if (s->type == STYPE_FIGHTER && s2->type == STYPE_CARRIER) {
  450. X        /* docking fighters with a carrier */
  451. X
  452. X    if(s->whatorbits==LEVEL_PLAN) {
  453. X                 openpdata(&dock_pdata);
  454. X                 getplanet(dock_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
  455. X            sh = p->ships;
  456. X
  457. X            if(sh == shipno) {
  458. X                p->ships = s->nextship;
  459. X                putplanet(dock_pdata, p, Stars[s->storbits]->planetpos[s->pnumorbits]);
  460. X                } else {
  461. X            openshdata(&dock_shdata);
  462. X                while(sh != shipno){
  463. X                (void)getship(dock_shdata, &s3, sh);
  464. X                sh3 = sh;
  465. X                sh = s3->nextship;
  466. X                if(sh != shipno) free(s3);    /* don't free it if it is the s3 we want */
  467. X                  }
  468. X              s3->nextship = s->nextship;
  469. X              putship(dock_shdata, s3, sh3);
  470. X            free(s3);
  471. X              if(sh3 == ship2no) { /* s3 was actually s2! */
  472. X                free(s2);
  473. X                (void)getship(dock_shdata, &s2, sh3);
  474. X            }
  475. X              close_file(dock_shdata);
  476. X
  477. X
  478. X            }
  479. X                  close_file(dock_pdata);
  480. X        } else if(s->whatorbits==LEVEL_STAR) {
  481. X                 openstardata(&dock_stdata);
  482. X                 getstar(dock_stdata, &Stars[s->storbits], s->storbits);
  483. X            sh = Stars[s->storbits]->ships;
  484. X
  485. X            if(sh == shipno) {
  486. X                 Stars[s->storbits]->ships = s->nextship;
  487. X                 putstar(dock_stdata, Stars[s->storbits], s->storbits);
  488. X            } else {
  489. X                openshdata(&dock_shdata);
  490. X                while(sh != shipno){
  491. X                         (void)getship(dock_shdata, &s3, sh);
  492. X                    sh3 = sh;
  493. X                    sh = s3->nextship;
  494. X                    if(sh != shipno) free(s3); /* don't free it if it is the s3 we want */
  495. X                    }
  496. X            s3->nextship = s->nextship;
  497. X            putship(dock_shdata, s3, sh3);
  498. X            free(s3);
  499. X            if(sh3 == ship2no) { /* we just wrote it to disk! */
  500. X                free(s2);
  501. X                (void)getship(dock_shdata, &s2, s3);
  502. X            }
  503. X            close(dock_shdata);
  504. X                
  505. X                }
  506. X
  507. X                 close_file(dock_stdata);
  508. X        } else {
  509. X            notify(Playernum, "Illegal scope.\n");
  510. X            free(s);
  511. X            free(s2);
  512. X            return;
  513. X        }
  514. X
  515. X
  516. X        s->fuel -= fuel;
  517. X        s->mass -= fuel * MASS_FUEL;
  518. X        s->is_docked = 1;
  519. X        s->whatdest = LEVEL_SHIP;
  520. X        s->whatorbits = LEVEL_UNIV;
  521. X        s->destshipno = ship2no;
  522. X        s->nextship = 0;
  523. X
  524. X        s->xpos = s2->xpos;
  525. X        s->ypos = s2->ypos;
  526. X
  527. X        s->object.number = s2->object.number;
  528. X        s->object.number4 = 1; /* docked with carrier */
  529. X
  530. X         /* remove fighter from upper level linked list */
  531. X        s2->object.number = shipno;
  532. X        s2->object.number4 += 1; /* number of fighters docked */
  533. X        s2->mass += s->mass;
  534. X
  535. X        } else {
  536. X       if (s2->is_docked && !Assault) {
  537. X        sprintf(buf,"ship #%d is already docked.\n",ship2no);
  538. X            notify(Playernum, buf);
  539. X        free(s);
  540. X        free(s2);
  541. X        return;
  542. X       }
  543. X
  544. X    if (Assault) {
  545. X
  546. X            openracedata(&dock_racedata);
  547. X        getrace(dock_racedata, &alien, (int)s2->owner);
  548. X        getrace(dock_racedata, &Race, Playernum); 
  549. X        close_file(dock_racedata);
  550. X
  551. X    sscanf(args[3],"%d",&boarders);
  552. X        if (boarders > MIN(s->popn, Max_crew(s2))
  553. X            || boarders <= 0) {
  554. X            sprintf(buf,"Illegal number of boarders (max can be %d).\n",
  555. X                MIN(s->popn, Max_crew(s2)));
  556. X            notify(Playernum, buf);
  557. X            free(alien);
  558. X            free(s);
  559. X            free(s2);
  560. X            return;
  561. X        }
  562. X        old2owner = s2->owner;
  563. X        s->popn -= boarders;
  564. X        s->mass -= boarders * Race->mass;
  565. X        sprintf(buf,"Boarding strength :%.2f       Defense strength: %.2f.\n", 
  566. X           bstrength = boarders * Race->fighters
  567. X            * .01 * Race->tech
  568. X            * .01 * (100 - s->damage),
  569. X        /* 1 is dummy armor */
  570. X
  571. X           b2strength = s2->popn * alien->fighters
  572. X            * .01 * alien->tech
  573. X            * .01 * (100 - s2->damage)
  574. X                );
  575. X    notify(Playernum, buf);
  576. X
  577. X    }
  578. X
  579. X
  580. X     /* the ship moves into position, regardless of success of attack */
  581. X    s->fuel -= fuel;
  582. X    s->mass -= fuel * MASS_FUEL;
  583. X
  584. X    s->xpos = s2->xpos + int_rand(-1,1);
  585. X    s->ypos = s2->ypos + int_rand(-1,1);
  586. X
  587. X    if (Assault) {
  588. X/* if the assaulted ship is docked, undock it first */
  589. X    if(s2->is_docked && s2->whatdest==LEVEL_SHIP) {
  590. X
  591. X        openshdata(&dock_shdata);
  592. X        getship(dock_shdata, &s3, s2->destshipno);
  593. X        s3->is_docked = 0;
  594. X        s3->whatdest = LEVEL_UNIV;
  595. X        s3->destshipno = 0;
  596. X        putship(dock_shdata, s3, s2->destshipno);
  597. X        close_file(dock_shdata);
  598. X        free(s3);
  599. X
  600. X        s2->is_docked = 0;
  601. X        s2->whatdest = LEVEL_UNIV;
  602. X        s2->destshipno = 0;
  603. X    }
  604. X         /* nuke both populations, ships */
  605. X    casualty_scale = MIN(boarders, s2->popn);
  606. X
  607. Xif(b2strength) {    /* otherwise the ship surrenders */
  608. X        casualties = int_rand(0, round_rand((float)casualty_scale * (b2strength+1.0) /
  609. X                  (bstrength+1.0)));
  610. X        casualties = MIN(boarders, casualties);
  611. X        boarders -= casualties;
  612. X
  613. X        dam = int_rand(0, round_rand(25. * (b2strength+1.0)/ (bstrength+1.0)));
  614. X            dam = MIN(100, dam);
  615. X        s->damage = MIN(100, s->damage+dam);
  616. X        if (s->damage >= 100)    
  617. X            kill_ship(Playernum, s);
  618. X
  619. X
  620. X           casualties2 = int_rand(0, round_rand((float)casualty_scale * (bstrength+1.0) / 
  621. X                (b2strength+1.0)));
  622. X           casualties2 = MIN(s2->popn, casualties2);
  623. X           s2->popn -= casualties2;
  624. X           s2->mass -= casualties2 * alien->mass;
  625. X            /* (their mass) */
  626. X           dam2 = int_rand(0,round_rand(25. * (bstrength+1.0)/(b2strength+1.0)));
  627. X           dam2 = MIN(100, dam2);
  628. X           s2->damage = MIN(100, s2->damage+dam2);
  629. X           if ( s2->damage >= 100) 
  630. X            kill_ship(Playernum, s2);
  631. X} else {
  632. X        s2->popn = 0; booby = 0;
  633. X/* do booby traps */
  634. X         /* check for boobytrapping */
  635. X        if (!Max_crew(s2) && s2->destruct > 0)
  636. X            booby = int_rand(0, 10*s2->destruct);
  637. X            booby = MIN(100, booby);
  638. X    }
  639. X
  640. X           if ((s2->popn == 0) &&  s->is_alive && s2->is_alive) {
  641. X                /* we got 'em */
  642. X            s->is_docked = 1;
  643. X            s->whatdest = LEVEL_SHIP;
  644. X            s->destshipno = ship2no;
  645. X
  646. X            s2->is_docked = 1;
  647. X            s2->whatdest = LEVEL_SHIP;
  648. X            s2->destshipno = shipno;
  649. X            old2owner = s2->owner;
  650. X            s2->owner = Playernum;
  651. X            s2->popn = boarders;
  652. X            s2->mass += boarders * Race->mass;    /* our mass */
  653. X           } else {        /* retreat */
  654. X            s->popn += boarders;
  655. X            s->mass += boarders * Race->mass;
  656. X           }
  657. X
  658. X/* races find out about each other */
  659. X    alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+5, 100);
  660. X    Race->translate[old2owner-1] = MIN(Race->translate[old2owner-1]+5, 100);
  661. X
  662. X    if(!boarders && s2->popn) /* boarding party killed */
  663. X        alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+25, 100);
  664. X    if(s2->owner==Playernum)    /* captured ship */
  665. X        Race->translate[old2owner-1] = MIN(Race->translate[old2owner-1]+25, 100);
  666. X
  667. X    openracedata(&dock_racedata);
  668. X    putrace(dock_racedata, Race, 7);
  669. X    putrace(dock_racedata, alien, 8);
  670. X    close_file(dock_racedata);
  671. X    free(alien);
  672. X    free(Race);
  673. X    } else {
  674. X        s->is_docked = 1;
  675. X        s->whatdest = LEVEL_SHIP;
  676. X        s->destshipno = ship2no;
  677. X
  678. X        s2->is_docked = 1;
  679. X        s2->whatdest = LEVEL_SHIP;
  680. X        s2->destshipno = shipno;
  681. X    }
  682. X
  683. X    if (Assault) {
  684. X        sprintf(telegram_buf,"%s #%d ASSAULTED by ",
  685. X            Shipnames[s2->type], ship2no);
  686. X             sprintf(buf,"%s #%d [%d] at %s\n", 
  687. X            Shipnames[s->type], shipno, s->owner, prin_ship_orbits(s2));
  688. X            str_cat(telegram_buf, buf);
  689. X        sprintf(buf,"Your damage: %d%%, theirs: %d%%.\n", dam2, dam);
  690. X            str_cat(telegram_buf, buf);
  691. X        if (!Max_crew(s2) && s2->destruct) {
  692. X               sprintf(buf,"(Your boobytrap gave them %.0f%% damage.)\n",
  693. X                booby);
  694. X            str_cat(telegram_buf, buf);
  695. X            sprintf(buf,"Their boobytrap gave you %.0f%% damage!)\n",
  696. X                booby);
  697. X            notify(Playernum, buf);
  698. X        }
  699. X        sprintf(buf,"Damage taken:  You: %d%% (now %d%%)\n", dam, s->damage);
  700. X            notify(Playernum, buf);
  701. Xif(!s->is_alive) {
  702. X  sprintf(buf,"              YOUR SHIP WAS DESTROYED!!!\n");
  703. X            notify(Playernum, buf);
  704. X  sprintf(buf,"              Their ship DESTROYED!!!\n");
  705. X        str_cat(telegram_buf, buf);
  706. X}
  707. X        sprintf(buf,"              Them: %d%% (now %d%%)\n",dam2,s2->damage);
  708. X            notify(Playernum, buf);
  709. Xif(!s2->is_alive) {
  710. X  sprintf(buf,"              Their ship DESTROYED!!!  Boarders are dead.\n");
  711. X            notify(Playernum, buf);
  712. X  sprintf(buf,"              YOUR SHIP WAS DESTROYED!!!\n");
  713. X        str_cat(telegram_buf, buf);
  714. X}
  715. X        if (s->is_alive) {
  716. X            if (s2->owner==Playernum) {
  717. X                sprintf(buf,"CAPTURED!\n");
  718. X                    str_cat(telegram_buf, buf);
  719. X                sprintf(buf,"VICTORY! the ship is yours!\n");
  720. X                    notify(Playernum, buf);
  721. X                if (boarders) {
  722. X                  sprintf(buf,"%d boarders move in.\n", boarders);
  723. X                    notify(Playernum, buf);
  724. X                    }
  725. X
  726. X            } else if(s2->popn) {
  727. X                sprintf(buf,"The boarding was repulsed; try again.\n");
  728. X                    notify(Playernum, buf);
  729. X                sprintf(buf,"You fought them off!\n");
  730. X                    str_cat(telegram_buf, buf);
  731. X            }
  732. X        } else {
  733. X            sprintf(buf,"The assault was too much for your bucket of bolts.\n");
  734. X                    notify(Playernum, buf);
  735. X            sprintf(buf,"The assault was too much for their ship..\n");
  736. X                str_cat(telegram_buf, buf);
  737. X        }
  738. X        if (s2->is_alive) {
  739. X            if (!boarders) {
  740. X                sprintf(buf,"Oh no! They killed your boarding party to the last man!\n");
  741. X                    notify(Playernum, buf);
  742. X            }
  743. X
  744. X            if (!s->popn) {
  745. X                sprintf(buf,"You killed all their crew!\n");
  746. X                str_cat(telegram_buf, buf);
  747. X            } 
  748. X        } else {
  749. X            sprintf(buf,"The assault weakened their ship too much!\n");
  750. X                notify(Playernum, buf);                
  751. X            sprintf(buf,"Your ship was weakened too much!\n");
  752. X                str_cat(telegram_buf, buf);
  753. X        }
  754. X        sprintf(buf,"Casualties: Yours: %d     Theirs: %d\n", casualties2, casualties);
  755. X            str_cat(telegram_buf, buf);
  756. X        sprintf(buf,"Crew casualties: Yours: %d     Theirs: %d\n", casualties, casualties2);
  757. X            notify(Playernum, buf);
  758. X            if(!notify(old2owner, telegram_buf))
  759. X                push_message(TELEG_PLAYER_AUTO, old2owner, telegram_buf, TELEGRAM);
  760. X    } else {
  761. X        sprintf(buf,"%s #%d docked with %s #%d.\n",
  762. X            Shipnames[s->type], shipno, 
  763. X            Shipnames[s2->type], ship2no);
  764. X            notify(Playernum, buf);
  765. X        }
  766. X
  767. X    } 
  768. X
  769. X        s->notified = s2->notified = 0;
  770. X           openshdata(&dock_shdata);
  771. X        putship(dock_shdata, s, shipno);
  772. X        putship(dock_shdata, s2, ship2no);
  773. X          close_file(dock_shdata);
  774. X        free(s2);
  775. X        free(s);
  776. X
  777. X
  778. X}
  779. END_OF_FILE
  780. if test 13087 -ne `wc -c <'server/dock.c'`; then
  781.     echo shar: \"'server/dock.c'\" unpacked with wrong size!
  782. fi
  783. # end of 'server/dock.c'
  784. if test -f 'server/doship.c' -a "${1}" != "-c" ; then 
  785.   echo shar: Renaming existing file \"'server/doship.c'\" to \"'server/doship.c.orig'\"
  786.   mv -f 'server/doship.c' 'server/doship.c.orig'
  787. fi
  788. echo shar: Extracting \"'server/doship.c'\" \(17924 characters\)
  789. sed "s/^X//" >'server/doship.c' <<'END_OF_FILE'
  790. X/*
  791. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  792. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  793. X * Restrictions in GB_copyright.h.
  794. X * doship -- do one ship turn.
  795. X */
  796. X
  797. X#include "GB_copyright.h"
  798. X#define EXTERN extern
  799. X#include "vars.h"
  800. X#include "ships.h"
  801. X#include "races.h"
  802. X#include "doturn.h"
  803. X#include "power.h"
  804. X#include "buffers.h"
  805. X#include <math.h>
  806. X#include <strings.h>
  807. X
  808. X
  809. Xdoship(shipno,ship)
  810. Xint shipno;
  811. Xshiptype *ship;
  812. X{
  813. X int sh,sh2,j,shfdata, doship_racedata;
  814. X boolean trigger;
  815. Xracetype *Race;
  816. X
  817. X/*ship is active */
  818. X    ship->active = 1;
  819. X
  820. X if (ship->is_alive && ship->owner) {
  821. X
  822. X/* for debugging */
  823. X    if(ship->popn > Max_crew(ship)) 
  824. X            ship->popn = Max_crew(ship);
  825. X    if(ship->destruct > Max_destruct(ship))
  826. X            ship->destruct = Max_destruct(ship);
  827. X    if(ship->fuel > (float)Max_fuel(ship))
  828. X            ship->fuel = (float)Max_fuel(ship);
  829. X
  830. X/* upgrade factory tech (if off) */
  831. X    if(ship->type==OTYPE_FACTORY && !ship->on) {
  832. X        openshdata(&doship_racedata);
  833. X        getrace(doship_racedata, &Race, ship->owner);
  834. X        close_file(doship_racedata);
  835. X        ship->tech = Race->tech;
  836. X        free(Race);
  837. X    }
  838. X
  839. X        /* repair radiation */
  840. X      if (ship->rad) {
  841. X    ship->active = 1;
  842. X            /* irradiated ships are immobile.. */
  843. X            /* kill off some people */
  844. X        /* check to see if ship is active */
  845. X        if(int_rand(1,100) <= ship->rad)
  846. X            ship->active = 0;
  847. X        ship->popn = round_rand(ship->popn * .80);
  848. X        if (ship->rad >= (int)REPAIR_RATE)
  849. X            ship->rad -= int_rand(0,(int)REPAIR_RATE);
  850. X        else
  851. X            ship->rad -= int_rand(0,ship->rad);
  852. X      } else
  853. X       ship->active = 1;
  854. X
  855. X      if(!ship->popn && Max_crew(ship) && !ship->is_docked)
  856. X    ship->whatdest = LEVEL_UNIV;
  857. X
  858. X
  859. X      if (ship->whatorbits != LEVEL_UNIV
  860. X      && Stars[ship->storbits]->nova_stage>0) {
  861. X        /* damage ships from supernovae */
  862. X    ship->damage += 5*Stars[ship->storbits]->nova_stage/(Armor(ship)+1);
  863. X    if (ship->damage >= 100) {
  864. X        kill_ship(1, ship);
  865. X        return;
  866. X    }
  867. X      }
  868. X
  869. X   if(ship->active)
  870. X    Moveship(shipno, ship);
  871. X
  872. X    ship->size = ship_size(ship);    /* for debugging */
  873. X
  874. X    if(ship->whatorbits != LEVEL_UNIV) {
  875. X/* printf("checking #%d\n",shipno); */
  876. X        StarsInhab[ship->storbits] = 1;
  877. X        setbit(Stars[ship->storbits]->inhabited, ship->owner);
  878. X        setbit(Stars[ship->storbits]->explored, ship->owner);
  879. X        if(ship->whatorbits == LEVEL_PLAN) {
  880. X            planets[ship->storbits][ship->pnumorbits]->info[ship->owner-1].explored = 1;
  881. X                    }
  882. X        }
  883. X/* just making sure */    
  884. X
  885. X
  886. X        /* add ships, popn to total count to add AP's */
  887. X    Power[ship->owner-1].ships_owned++;
  888. X    Power[ship->owner-1].resource += ship->resource;
  889. X    Power[ship->owner-1].fuel += ship->fuel;
  890. X    Power[ship->owner-1].destruct += ship->destruct;
  891. X    Power[ship->owner-1].popn += ship->popn;
  892. X
  893. X    if (ship->whatorbits==LEVEL_UNIV) {
  894. X         Sdatanumships[ship->owner-1]++;
  895. X         Sdatapopns[ship->owner] += ship->popn;
  896. X    } else {
  897. X        starnumships[ship->storbits][ship->owner-1]++; 
  898. X             /* add popn of ships to popn */
  899. X            starpopns[ship->storbits][ship->owner-1] += ship->popn;
  900. X         /* set inhabited for ship */
  901. X        StarsInhab[ship->storbits] = 1;
  902. X        setbit(Stars[ship->storbits]->inhabited, ship->owner);
  903. X        setbit(Stars[ship->storbits]->explored, ship->owner);
  904. X    }
  905. X
  906. X
  907. X
  908. X
  909. X    if (ship->active) {
  910. X
  911. X        /* bombard the planet */
  912. X       if (can_bombard(ship) && ship->bombard
  913. X            && ship->whatorbits==LEVEL_PLAN
  914. X            && ship->whatdest==LEVEL_PLAN
  915. X            && ship->deststar== ship->storbits
  916. X            && ship->destpnum== ship->pnumorbits) {
  917. X                /* ship bombards planet */
  918. X        Stinfo[ship->storbits][ship->pnumorbits].inhab = 1;
  919. X       }
  920. X
  921. X
  922. X
  923. X           /* repair ship by the amount of crew it has */
  924. X           /* industrial complexes can repair (robot ships
  925. X          and offline factories can't repair) */
  926. X    if (ship->damage && Repair(ship)) {
  927. X             reg int drep,cost;
  928. X             reg float maxrep;
  929. X             maxrep = REPAIR_RATE;
  930. X           /* stations repair for free, and ships docked with them */
  931. X         if (ship->type==STYPE_STATION || !Shipdata[ship->type][ABIL_BUILD]
  932. X        || (ship->is_docked && ship->whatdest==LEVEL_SHIP && 
  933. X         ships[ship->destshipno]->type==STYPE_STATION) )
  934. X          cost = 0.0;
  935. X         else {
  936. X         maxrep *= (float)ship->popn / (float)Max_crew(ship);
  937. X         cost = 0.005 * maxrep * Cost(ship);
  938. X         }
  939. X
  940. X         if (cost > ship->resource) 
  941. X              { 
  942. X         drep = (int)maxrep * ship->resource / cost;
  943. X                ship->resource = 0; 
  944. X        } else { 
  945. X              ship->resource -= cost; 
  946. X        drep = (int)maxrep;
  947. X          }
  948. X
  949. X         ship->mass -= cost * MASS_RESOURCE;
  950. X
  951. X         if (drep > ship->damage) ship->damage = 0;
  952. X                else 
  953. X          ship->damage -= drep;
  954. X     }
  955. X
  956. X/* compute the mass of the ship (there is a wierd bug that changes
  957. X   mass the wrong way) */
  958. X    ship->mass = ((ship->type==OTYPE_TOXWC) ? 1.0 : Mass(ship))
  959. X        + (float)ship->popn*races[ship->owner-1]->mass
  960. X        + (float)ship->resource*MASS_RESOURCE
  961. X          + (float)ship->fuel*MASS_FUEL
  962. X        + (float)ship->destruct*MASS_DESTRUCT;
  963. X
  964. X     switch (ship->type) {
  965. X
  966. X      case OTYPE_CANIST:
  967. X       if (ship->whatorbits == LEVEL_PLAN && !ship->is_docked) { short *t;
  968. X          if (--ship->object.number) {
  969. X        if ( Stinfo[ship->storbits][ship->pnumorbits].temp_add < -90 )
  970. X          Stinfo[ship->storbits][ship->pnumorbits].temp_add = -100;
  971. X        else  
  972. X          Stinfo[ship->storbits][ship->pnumorbits].temp_add -= 10;
  973. X          } else {    /* timer expired; destroy canister */
  974. X           reg int j=0;
  975. X
  976. X          kill_ship(1, ship);
  977. X          sprintf(telegram_buf,"Notice from /%s/%s\n", 
  978. X               Stars[ship->storbits]->name, 
  979. X               Stars[ship->storbits]->pnames[ship->pnumorbits]);
  980. X          sprintf(buf, "Canister of dust previously covering this planet has dissipated.\n");
  981. X            str_cat(telegram_buf, buf);
  982. X          for (j=1; j<=Num_races; j++)
  983. X               if (planets[ship->storbits][ship->pnumorbits]->info[j-1].numsectsowned) 
  984. X                push_message(TELEG_PLAYER_AUTO, j, telegram_buf, TELEGRAM);
  985. X          }
  986. X       }
  987. X       break;
  988. X
  989. X      case STYPE_MIRROR:
  990. X      switch (ship->aimed_at.level) {
  991. X       case LEVEL_SHIP: /* ship aimed at is a legal ship now */
  992. X              /* if in the same system */
  993. X        if ( (ship->whatorbits==LEVEL_STAR || ship->whatorbits==LEVEL_PLAN)
  994. X           && (ships[ship->aimed_at.shipno]!=NULL)
  995. X           && (ships[ship->aimed_at.shipno]->whatorbits==LEVEL_STAR ||
  996. X            ships[ship->aimed_at.shipno]->whatorbits==LEVEL_PLAN)
  997. X           && ship->storbits == ships[ship->aimed_at.shipno]->storbits 
  998. X           && ships[ship->aimed_at.shipno]->is_alive ) {
  999. X                shiptype *s;
  1000. X                  reg int i;
  1001. X                  float range;
  1002. X                s = ships[ship->aimed_at.shipno];
  1003. X          range = sqrt(Distsq(ship->xpos, ship->ypos,s->xpos,s->ypos));
  1004. X          i = int_rand(0,round_rand((2./((float)Size(s)))
  1005. X            *(float)ship->aimed_at.intensity/(range/PLORBITSIZE+1.0)));
  1006. X      sprintf(telegram_buf, "Space Mirror #%d %s [owner %d] aimed at ",
  1007. X          shipno, ship->name, ship->owner);
  1008. X        str_cat(telegram_buf, buf);
  1009. X      sprintf(buf, "%s #%d %s [owner %d] !\n",Shipnames[s->type],
  1010. X          ship->aimed_at.shipno, s->name, s->owner);
  1011. X        str_cat(telegram_buf, buf);
  1012. X                s->damage += i;
  1013. X                if(i) {
  1014. X      sprintf(buf, "\n%d%% damage done.\n",i);
  1015. X        str_cat(telegram_buf, buf); 
  1016. X                }
  1017. X                if (s->damage >= 100) {
  1018. X      sprintf(buf, "%s #%d DESTROYED!!!\n",Shipnames[s->type],
  1019. X          ship->aimed_at.shipno);
  1020. X                    kill_ship(ship->owner, s);
  1021. X                      }
  1022. X
  1023. X push_message(TELEG_PLAYER_AUTO, s->owner, telegram_buf, TELEGRAM);
  1024. X push_message(TELEG_PLAYER_AUTO, ship->owner, telegram_buf, TELEGRAM);
  1025. X            }
  1026. X        break;
  1027. X       case LEVEL_PLAN: { reg short *t; 
  1028. X                  reg int i;
  1029. X                  float range;
  1030. X          range = sqrt(Distsq(ship->xpos, ship->ypos,
  1031. X            Stars[ship->storbits]->xpos
  1032. X               +planets[ship->storbits][ship->pnumorbits]->xpos,
  1033. X            Stars[ship->storbits]->ypos
  1034. X               +planets[ship->storbits][ship->pnumorbits]->ypos));
  1035. X
  1036. X          if ( range > PLORBITSIZE ) 
  1037. X              i = PLORBITSIZE * ship->aimed_at.intensity/range;
  1038. X          else
  1039. X              i = ship->aimed_at.intensity;
  1040. X
  1041. X        i = round_rand(.01*(100.0-(float)ship->damage)*(float)i);
  1042. X          Stinfo[ship->storbits][ship->aimed_at.pnum].temp_add += i;
  1043. X
  1044. X        } break;
  1045. X
  1046. X       case LEVEL_STAR: { float range;
  1047. X          /* have to be in the same system as the star; otherwise
  1048. X              it's not too fair.. */
  1049. X        if (ship->aimed_at.snum>0 && 
  1050. X            ship->aimed_at.snum < Sdata.numstars &&
  1051. X            ship->whatorbits > LEVEL_UNIV &&
  1052. X            ship->aimed_at.snum == ship->storbits)
  1053. X            Stars[ship->aimed_at.snum]->stability += random()&01;
  1054. X        } break;
  1055. X       case LEVEL_UNIV:
  1056. X        break;
  1057. X    }
  1058. X    break;
  1059. X     case STYPE_GOD:
  1060. X        /* gods have infinite power.... heh heh heh */
  1061. X    ship->fuel = Max_fuel(ship);
  1062. X    ship->popn = Max_crew(ship);
  1063. X    ship->destruct = Max_destruct(ship);
  1064. X    ship->resource = Max_resource(ship);
  1065. X    break;
  1066. X
  1067. X     case OTYPE_AP:    /* atmospheric processor */
  1068. X        /* if landed on planet, change conditions to be like race */
  1069. X    if (ship->is_docked && ship->whatdest==LEVEL_PLAN && ship->on) {
  1070. X        int j,d,a;planettype *p;
  1071. X        p = planets[ship->storbits][ship->pnumorbits];
  1072. X        if (ship->fuel >= 3.0) {
  1073. X            ship->fuel -= 3.0;
  1074. X            for (j=RTEMP+1; j<=OTHER; j++) {
  1075. X                if ( (d = races[ship->owner-1]->conditions[j] - 
  1076. X                      p->conditions[j]) != 0) {
  1077. X       
  1078. X                  a = sgn(d)*int_rand(-1,
  1079. X           round_rand(MIN(3,d*sgn(d))
  1080. X       *(float)ship->popn/(float)Shipdata[OTYPE_AP][ABIL_MAXCREW]));
  1081. X                  if (p->conditions[j] + a < 0)
  1082. X                    p->conditions[j] = 0;
  1083. X                  else if (p->conditions[j] + a > 100)
  1084. X                    p->conditions[j] = 100;
  1085. X                  else p->conditions[j] += a;
  1086. X                }
  1087. X            }
  1088. X        } else if (!ship->notified) {
  1089. X            ship->notified = 1;
  1090. X            msg_OOF(ship, shipno, telegram_buf);
  1091. X        }
  1092. X    }
  1093. X    break;
  1094. X
  1095. X     case OTYPE_VN:    /* Von Neumann machine */
  1096. X    do_VN(ship,shipno);
  1097. X    break;
  1098. X
  1099. X     case OTYPE_BERS:    /* Berserker */
  1100. X        /* (turn done in doplanet() ) */
  1101. X    break;
  1102. X
  1103. X     case STYPE_ASS:
  1104. X     /* "indimidate" the planet below, for enslavement purposes. */
  1105. X    if (ship->whatorbits==LEVEL_PLAN)
  1106. X        Stinfo[ship->storbits][ship->pnumorbits].intimidated = 1;
  1107. X    break;
  1108. X
  1109. X     case OTYPE_OMCL:
  1110. X     /* orbital mind control laser */
  1111. X    if (ship->aimed_at.level==LEVEL_PLAN && ship->on &&
  1112. X        ship->speed==1) {
  1113. X        planets[ship->aimed_at.snum][ship->aimed_at.pnum]
  1114. X            ->is_sheep = 1;
  1115. X    }
  1116. X    break;
  1117. X
  1118. X     case STYPE_HABITAT:{ reg int add;
  1119. X     /* habitats multiply some resources inside them. */
  1120. X    add = ship->resource *
  1121. X        ((float)ship->popn / Shipdata[STYPE_HABITAT][ABIL_MAXCREW]) 
  1122. X             * (100 - ship->damage) * 0.0005;
  1123. X    if (ship->resource+add > Shipdata[STYPE_HABITAT][ABIL_CARGO])
  1124. X        add = Shipdata[STYPE_HABITAT][ABIL_CARGO] - ship->resource;
  1125. X    ship->resource += add;
  1126. X    ship->mass += add * MASS_RESOURCE;
  1127. X    add = ship->popn * races[ship->owner-1]->birthrate * 
  1128. X        (100 - ship->damage) * 0.002;
  1129. X    if (ship->popn+add > Shipdata[STYPE_HABITAT][ABIL_MAXCREW])
  1130. X        add = Shipdata[STYPE_HABITAT][ABIL_MAXCREW] - ship->popn;
  1131. X    ship->popn += add;
  1132. X    ship->mass += add * races[ship->owner-1]->mass;
  1133. X    } break;
  1134. X
  1135. X     case STYPE_POD:
  1136. X      if (ship->notified) {
  1137. X        /* we just arrived at this system -- explode */
  1138. X        /* or, we are floating in space with no fuel -- just die */
  1139. X        reg int i,f;
  1140. X
  1141. X    f = -1;
  1142. X        kill_ship(1, ship);
  1143. X        if (ship->whatorbits==LEVEL_STAR) {
  1144. X
  1145. X          i = int_rand(0,Stars[ship->storbits]->numplanets - 1);
  1146. X
  1147. X             if(int_rand(1,4)==1)
  1148. X                f = i;
  1149. X
  1150. X          sprintf(telegram_buf, "Bulletin\n\nSpore pod #%d has warmed and exploded.\n",shipno);
  1151. X           if (f != -1) {
  1152. X            sprintf(buf,"A spore has landed on planet %s.\n",Stars[ship->storbits]->pnames[f]);
  1153. X            Stinfo[ship->storbits][f].Thing_add = ship->owner;
  1154. X                /* so doplanet does not pass over it */
  1155. X        StarsInhab[ship->storbits] = 1;
  1156. X            setbit(Stars[ship->storbits]->inhabited,ship->owner);
  1157. X            setbit(Stars[ship->storbits]->explored, ship->owner);
  1158. X            planets[ship->storbits][f]->info[ship->owner-1].explored = 1;
  1159. X          } else {
  1160. X            sprintf(buf,"No spores have survived.\n");
  1161. X          }
  1162. X            str_cat(telegram_buf, buf);
  1163. X    push_message(TELEG_PLAYER_AUTO, ship->owner, telegram_buf); 
  1164. X          sprintf(telegram_buf,"BULLETIN!\n\n A spore pod has exploded in system /%s.\n",
  1165. X            Stars[ship->storbits]->name);
  1166. X          sprintf(buf, "Spores may have drifted to planets here.\n");
  1167. X            str_cat(telegram_buf, buf);
  1168. X          for (i=1; i<=Num_races; i++)
  1169. X            if (i!=ship->owner && isset(Stars[ship->storbits]->inhabited,i))
  1170. X    push_message(TELEG_PLAYER_AUTO, i, telegram_buf, TELEGRAM);
  1171. X
  1172. X       }
  1173. X     }
  1174. X     break;
  1175. X
  1176. X     default:
  1177. X    break;
  1178. X    }
  1179. X
  1180. X   }
  1181. X
  1182. X } else if (!ship->is_alive && !ship->notified) {
  1183. X     /* ship is dead -- add to shipfree file, remove from all lists. */
  1184. X     /* if notified, this means it's already been deleted and written. */
  1185. X/*    printf("destroyed ship #%d\n",shipno);*/
  1186. X    if (ship->type == OTYPE_VN || ship->type==OTYPE_BERS) {
  1187. X
  1188. X         /* add ship to VN shit list */
  1189. X
  1190. X        if (ship->object.number3>0 && ship->object.number3<=Num_races 
  1191. X            && ship->object.number3 != ship->owner) {
  1192. X         Sdata.VN_hitlist[ship->object.number3-1] += ship->object.number;
  1193. X
  1194. X          /* keep track of where these VN's were shot up */
  1195. X
  1196. X         if (Sdata.VN_index1[ship->object.number3-1] == -1)
  1197. X             /* there's no star in the first index */
  1198. X            Sdata.VN_index1[ship->object.number3-1] = ship->storbits;
  1199. X         else if (Sdata.VN_index2[ship->object.number3-1] == -1)
  1200. X             /* there's no star in the second index */
  1201. X            Sdata.VN_index2[ship->object.number3-1] = ship->storbits;
  1202. X         else {
  1203. X             /* pick an index to supplant */
  1204. X            if (random()&01)
  1205. X            Sdata.VN_index1[ship->object.number3-1] = ship->storbits;
  1206. X            else
  1207. X            Sdata.VN_index2[ship->object.number3-1] = ship->storbits;
  1208. X         }
  1209. X         printf("\t-- added %d ships, player %d\n",
  1210. X                ship->object.number, ship->object.number3);
  1211. X        }
  1212. X    }
  1213. X    ship->notified = 1;
  1214. X    makeshipdead(shipno);
  1215. X    }
  1216. X
  1217. X}
  1218. X
  1219. X
  1220. Xdomine(shipno, detonate)
  1221. Xint shipno;
  1222. Xint detonate;
  1223. X{
  1224. X int sh,sh2,j,shfdata,pdata,rdata,hits;
  1225. X boolean trigger;
  1226. X shiptype *s, *ship;
  1227. X planettype *planet;
  1228. X racetype *r;
  1229. X
  1230. X openshdata(&shfdata);
  1231. X getship(shfdata, &ship, shipno);
  1232. X close_file(shfdata);
  1233. Xif(ship->is_alive && ship->owner)
  1234. Xswitch(ship->type) {
  1235. X      case STYPE_MINE:
  1236. X        /* check around and see if we should explode. */
  1237. X       if (ship->on || detonate) {
  1238. X        int rad=0; int dam=0; double xd,yd,range; int p;
  1239. X
  1240. X        switch(ship->whatorbits) {
  1241. X          case LEVEL_STAR:
  1242. X            sh = Stars[ship->storbits]->ships;
  1243. X            break;
  1244. X          case LEVEL_PLAN:
  1245. X            openpdata(&pdata);
  1246. X            getplanet(pdata, &planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
  1247. X            sh = planet->ships;
  1248. X            close_file(pdata);
  1249. X            free(planet);
  1250. X            break;
  1251. X          default:
  1252. X            free(ship);
  1253. X            return;
  1254. X            break;
  1255. X        }
  1256. X        
  1257. X         sh2 = sh;
  1258. X          /* traverse the list, look for ships that 
  1259. X            are closer than the trigger radius... */
  1260. X/*printf("found mine  sh = %d rad = %d\n",sh,rad);*/
  1261. X        rad = 0;
  1262. X        if(!detonate) {
  1263. X        openracedata(&rdata);
  1264. X        getrace(rdata, &r, ship->owner);
  1265. X        close_file(rdata);
  1266. X
  1267. X        openshdata(&shfdata);
  1268. X            while (sh && !rad) {
  1269. X        getship(shfdata, &s, sh);        
  1270. X            getship(shfdata, &s, sh);        
  1271. X            if(s->is_docked && s->whatdest==LEVEL_PLAN) {
  1272. X                xd = ship->xpos;
  1273. X                yd = ship->ypos;
  1274. X            } else {
  1275. X                xd = s->xpos - ship->xpos;
  1276. X                yd = s->ypos - ship->ypos;
  1277. X            }
  1278. X            range = sqrt(xd*xd + yd*yd);
  1279. X                
  1280. X        if( !isset(r->allied, s->owner) && 
  1281. X           (s->owner != ship->owner) && 
  1282. X           ( (int)range <= ship->object.number) )
  1283. X             rad = 1;
  1284. X        else
  1285. X             sh = s->nextship;
  1286. X
  1287. X        free(s);
  1288. X            }
  1289. X        close_file(shfdata);
  1290. X        free(r);
  1291. X        } else
  1292. X        rad = 1;
  1293. X/*printf("rad = %d\n",rad);*/
  1294. X         if (rad) {
  1295. X          char telegram_not[1000];
  1296. X        kill_ship(ship->owner, ship);
  1297. X        sprintf(telegram_buf, "Mine #%d triggered at %s\n",
  1298. X                shipno,prin_ship_orbits(ship));
  1299. X
  1300. X        /* I have made the blast radius equal to the trigger radius.*/
  1301. X        /* -R. */
  1302. X
  1303. X        sh = sh2 ;   /* Make sh start from beginning of the list */
  1304. X        openshdata(&shfdata);
  1305. X        while (sh) {
  1306. X            getship(shfdata, &s, sh);        
  1307. X            if(s->is_docked && s->whatdest==LEVEL_PLAN) {
  1308. X                xd = ship->xpos;
  1309. X                yd = ship->ypos;
  1310. X            } else {
  1311. X                xd = s->xpos - ship->xpos;
  1312. X                yd = s->ypos - ship->ypos;
  1313. X            }
  1314. X            range = sqrt(xd*xd + yd*yd);
  1315. X            if(!detonate)
  1316. X            trigger = (int_rand(1,100)<= 2 * Size(s));
  1317. X
  1318. X           if (s->is_alive && sh != shipno &&
  1319. X             (detonate || (range <= ship->object.number && trigger))) {
  1320. X
  1321. X             if (!ship->mode) {
  1322. X             /* radiation mine */
  1323. X
  1324. X            hits =MIN(ship->destruct,
  1325. X                  (int)(ship->destruct/(range/100.0+1.0)));
  1326. X            rad = MAX(0, 20*(hits - Armor(s)) / Size(s));
  1327. X
  1328. X            rad = int_rand(0, rad);
  1329. X            rad = MIN(rad ,100);
  1330. X
  1331. X            if (rad > s->rad) {
  1332. X            s->rad = MAX(rad, s->rad);
  1333. X            if(int_rand(1,100) <= s->rad)
  1334. X                s->active = 0;
  1335. X            
  1336. X                 sprintf(telegram_not, "%s #%d %s irradiated by mine #%d\n", Shipnames[s->type], sh, s->name, shipno);
  1337. X                 sprintf(buf," at %s - dosage %d%%\n",prin_ship_orbits(s), rad);
  1338. X            str_cat(telegram_not, buf);
  1339. X    push_message(TELEG_PLAYER_AUTO, s->owner, telegram_not, TELEGRAM);
  1340. X                 sprintf(buf,"%s #%d [%d] received %d%% dosage\n",
  1341. X                Shipnames[s->type], sh, 
  1342. X                    s->owner, rad);
  1343. X        str_cat(telegram_buf, buf);
  1344. X            }
  1345. X
  1346. X              } else {
  1347. X            int totaldam;    
  1348. X             /* explosive mine */
  1349. X
  1350. X            hits =MIN(ship->destruct,
  1351. X                  (int)(ship->destruct/(range/100.0+1.0)));
  1352. X            dam = MAX(0, 20*(hits - Armor(s)) / Size(s));
  1353. X            
  1354. X            dam = int_rand(0, dam);
  1355. X            dam = MIN(100, dam);
  1356. X            if (dam) {
  1357. X               s->damage = MIN(100, s->damage+dam);
  1358. X               sprintf(telegram_not, "%s #%d %s damaged by mine #%d\n",
  1359. X                     Shipnames[s->type], sh, s->name, shipno);
  1360. X               sprintf(buf," at %s - %d %% damage", prin_ship_orbits(ship), dam);
  1361. X                    str_cat(telegram_not, buf);
  1362. X               sprintf(buf,"%s #%d [%d] received %d%% damage\n",
  1363. X                Shipnames[s->type], sh, 
  1364. X                s->owner, dam);
  1365. X                str_cat(telegram_buf, buf);
  1366. X               if (s->damage >= 100) {
  1367. X                kill_ship(ship->owner, s);
  1368. X                sprintf(buf, " %s #%d DESTROYED\n",Shipnames[s->type],sh);
  1369. X                    str_cat(telegram_not, buf);
  1370. X                sprintf(buf,"\t--DESTROYED\n");
  1371. X                    str_cat(telegram_buf, buf);
  1372. X               }
  1373. X               if(!notify(s->owner, telegram_not))
  1374. X               push_message(TELEG_PLAYER_AUTO, s->owner, telegram_not, TELEGRAM);
  1375. X            }
  1376. X               }
  1377. X
  1378. X            putship(shfdata, s, sh);        
  1379. X             }
  1380. X
  1381. X             sh = s->nextship;
  1382. X            free(s);
  1383. X        }
  1384. X        close_file(shfdata);
  1385. X         }
  1386. X        if(!notify(ship->owner, telegram_buf))
  1387. X        push_message(TELEG_PLAYER_AUTO, ship->owner, telegram_buf,
  1388. X                 TELEGRAM); 
  1389. X
  1390. X        openshdata(&shfdata);
  1391. X        putship(shfdata, ship, shipno);
  1392. X        close_file(shfdata);
  1393. X        }
  1394. X       break;
  1395. X     default:
  1396. X       break;
  1397. X       }
  1398. Xfree(ship);
  1399. X}
  1400. X
  1401. END_OF_FILE
  1402. if test 17924 -ne `wc -c <'server/doship.c'`; then
  1403.     echo shar: \"'server/doship.c'\" unpacked with wrong size!
  1404. fi
  1405. # end of 'server/doship.c'
  1406. if test -f 'server/name.c' -a "${1}" != "-c" ; then 
  1407.   echo shar: Renaming existing file \"'server/name.c'\" to \"'server/name.c.orig'\"
  1408.   mv -f 'server/name.c' 'server/name.c.orig'
  1409. fi
  1410. echo shar: Extracting \"'server/name.c'\" \(17264 characters\)
  1411. sed "s/^X//" >'server/name.c' <<'END_OF_FILE'
  1412. X/*
  1413. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
  1414. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
  1415. X * Restrictions in GB_copyright.h.
  1416. X *
  1417. X * name.c -- rename something to something else
  1418. X* announce.c -- make announcements in the system you currently in.
  1419. X*            You must be inhabiting that system for your message to sent.
  1420. X*            You must also be in that system (and inhabiting) to receive announcements.
  1421. X* page.c -- send a message to a player requesting his presence in a system. 
  1422. X*/
  1423. X
  1424. X#include "GB_copyright.h"
  1425. X#define EXTERN extern
  1426. X#include "vars.h"
  1427. X#include "races.h"
  1428. X#include "ships.h"
  1429. X#include "buffers.h"
  1430. X#include <ctype.h>
  1431. X#include <signal.h>
  1432. X#include <strings.h>
  1433. X#include <time.h>
  1434. Xint name_shdata,name_stardata, name_racedata, name_pdata;
  1435. Xint i;
  1436. X
  1437. Xchar msg[1024];
  1438. Xstruct tm *current_tm;/* for watching for next update */
  1439. Xlong clk;
  1440. X
  1441. Xgive(Playernum, APcount, argn, args)
  1442. Xint Playernum;
  1443. Xint APcount;
  1444. Xint argn;
  1445. Xchar args[MAXARGS][COMMANDSIZE];
  1446. X{
  1447. Xint who, sh;
  1448. Xshiptype *ship;
  1449. Xplanettype *planet;
  1450. Xracetype *Race, *alien;
  1451. X
  1452. XGetPlayer(args[1], &who, &alien);
  1453. X   if (who < 1 || who > Numraces() ) {
  1454. X    sprintf(buf,"No such player.\n");
  1455. X        notify(Playernum, buf);
  1456. X    return;
  1457. X   }
  1458. X
  1459. Xopenracedata(&name_racedata);
  1460. Xgetrace(name_racedata, &Race, Playernum);
  1461. Xclose_file(name_racedata);
  1462. X
  1463. X/* check to see if both players are mutually allied */
  1464. Xif(!(isset(Race->allied, who) && isset(alien->allied, Playernum))) {
  1465. X      notify(Playernum, "You two are not mutually allied.\n");
  1466. X      free(Race);
  1467. X      free(alien);
  1468. X      return;
  1469. X}
  1470. Xsscanf(args[2]+(args[2][0]=='#'), "%d", &sh);
  1471. X
  1472. X        openshdata(&name_shdata);
  1473. X        if(!getship(name_shdata, &ship, sh)) {
  1474. X            notify(Playernum, "Illegal ship number.\n");
  1475. X            close_file(name_shdata);
  1476. X            free(Race);
  1477. X            free(alien);
  1478. X            return;
  1479. X        }
  1480. X        close_file(name_shdata);
  1481. X
  1482. X                if(ship->owner != Playernum || !ship->is_alive) {
  1483. X            DontOwnErr(Playernum, sh);
  1484. X            free(ship);
  1485. X            free(Race);
  1486. X            free(alien);
  1487. X            return;
  1488. X        }
  1489. Xif(ship->type == STYPE_POD) {
  1490. X    notify(Playernum, "You cannot change the ownership of spore pods.\n");
  1491. X    free(ship);
  1492. X    free(Race);
  1493. X    free(alien);
  1494. X    return;
  1495. X}
  1496. X
  1497. Xif(ship->popn && !Race->God) {
  1498. X    notify(Playernum, "You can't give this ship away while it has crew on board.\n");
  1499. X    free(ship);
  1500. X    free(Race);
  1501. X    free(alien);
  1502. X    return;
  1503. X    }
  1504. X
  1505. Xswitch(ship->whatorbits) { 
  1506. X    case LEVEL_UNIV:
  1507. X        if(!enufAP(Playernum, Sdata.AP[Playernum-1], APcount)) {
  1508. X            free(Race);
  1509. X            free(alien);
  1510. X            free(ship);
  1511. X            return;
  1512. X            }
  1513. X        break;
  1514. X    default:
  1515. X        if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
  1516. X            free(Race);
  1517. X            free(alien);
  1518. X            free(ship);
  1519. X            return;
  1520. X            }
  1521. X            break;
  1522. X    }
  1523. X
  1524. Xopenshdata(&name_shdata);
  1525. Xship->owner = who;
  1526. Xputship(name_shdata, ship, sh);
  1527. Xclose_file(name_shdata);
  1528. X
  1529. X/* set inhabited/explored bits */
  1530. Xswitch(ship->whatorbits) {
  1531. X  case LEVEL_UNIV:
  1532. X    break;
  1533. X  case LEVEL_STAR:
  1534. X    free(Stars[ship->storbits]);
  1535. X    openstardata(&name_stardata);
  1536. X    getstar(name_stardata, &(Stars[ship->storbits]), ship->storbits);
  1537. X    setbit(Stars[ship->storbits]->inhabited, who);
  1538. X    setbit(Stars[ship->storbits]->explored, who);
  1539. X    putstar(name_stardata, Stars[ship->storbits], ship->storbits);
  1540. X    close_file(name_stardata);
  1541. X    break;
  1542. X  case LEVEL_PLAN:
  1543. X    free(Stars[ship->storbits]);
  1544. X    openstardata(&name_stardata);
  1545. X    getstar(name_stardata, &(Stars[ship->storbits]), ship->storbits);
  1546. X    setbit(Stars[ship->storbits]->inhabited, who);
  1547. X    setbit(Stars[ship->storbits]->explored, who);
  1548. X    putstar(name_stardata, Stars[ship->storbits], ship->storbits);
  1549. X    close_file(name_stardata);
  1550. X
  1551. X    openpdata(&name_pdata);
  1552. X    getplanet(name_pdata, &planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
  1553. X    planet->info[who-1].explored = 1;
  1554. X    putplanet(name_pdata, planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
  1555. X    close_file(name_pdata);
  1556. X    free(planet);
  1557. X
  1558. X    break;
  1559. X  default:
  1560. X    notify(Playernum, "Something wrong with this ship's scope.\n");
  1561. X    free(ship);
  1562. X    free(Race);
  1563. X    free(alien);
  1564. X    return;
  1565. X    break;
  1566. X}
  1567. X
  1568. Xswitch(ship->whatorbits) { 
  1569. X    case LEVEL_UNIV:
  1570. X        deductAPs(Playernum, APcount, 0, 1);
  1571. X        free(Race);
  1572. X        free(alien);
  1573. X        free(ship);
  1574. X        return;
  1575. X        break;
  1576. X    default:
  1577. X        deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
  1578. X        break;
  1579. X    }
  1580. X
  1581. X
  1582. Xnotify(Playernum, "Owner changed.\n");
  1583. Xsprintf(buf, "%s [%d] gave you %s #%d at %s.\n", Race->name, Playernum,
  1584. X    Shipnames[ship->type], sh, prin_ship_orbits(ship));
  1585. Xnotify(who, buf);
  1586. Xpush_message(TELEG_PLAYER_AUTO, who, buf, TELEGRAM);
  1587. X
  1588. Xsprintf(buf, "%s [%d] gives %s [%d] a ship.\n", Race->name, alien->name);
  1589. X
  1590. Xfor(i=1; i<=Numraces(); i++)
  1591. X    push_message(TELEG_PLAYER_AUTO, who, buf, TRANSFER);
  1592. X
  1593. Xfree(ship);
  1594. Xfree(Race);
  1595. Xfree(alien);
  1596. X
  1597. X}
  1598. X
  1599. X
  1600. Xpage(Playernum, APcount0, argn, args)
  1601. Xint Playernum;
  1602. Xint APcount0;
  1603. Xint argn;
  1604. Xchar args[MAXARGS][COMMANDSIZE];
  1605. X{
  1606. Xint i, who, to_block, dummy, APcount;
  1607. Xracetype *Race, *alien;
  1608. X
  1609. XAPcount = APcount0;
  1610. Xto_block = 0;
  1611. Xif(!strncmp(args[1], "block", strlen(args[1]))) {
  1612. X    to_block = 1;
  1613. X    notify(Playernum, "Paging alliance block.\n");
  1614. X} else {
  1615. X   GetPlayer(args[1], &who, &alien);
  1616. X   if (who < 1 || who > Numraces() ) {
  1617. X    sprintf(buf,"No such player.\n");
  1618. X        notify(Playernum, buf);
  1619. X    return;
  1620. X   }
  1621. XAPcount *= !alien->God;
  1622. Xfree(alien);
  1623. X}
  1624. X
  1625. X    switch(Dir[Playernum-1].level) {
  1626. X        case LEVEL_UNIV:
  1627. X            sprintf(buf, "You can't make pages at universal scope.\n");
  1628. X            notify(Playernum, buf);
  1629. X            break;
  1630. X        default:
  1631. X            openstardata(&name_stardata);
  1632. X            free(Stars[Dir[Playernum-1].snum]);
  1633. X        getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
  1634. X            close_file(name_stardata);
  1635. X            if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
  1636. X                free(Race);
  1637. X                return;
  1638. X        }
  1639. X
  1640. X        openracedata(&name_racedata);
  1641. X        getrace(name_racedata, &Race, Playernum); 
  1642. X        close_file(name_racedata);
  1643. X
  1644. X        sprintf(buf, "%s page(s) you from the %s star system.\n",
  1645. X            Race->name, Stars[Dir[Playernum-1].snum]->name);
  1646. X        free(Race);
  1647. X
  1648. X        if(to_block) {
  1649. X          dummy = (Blocks[Playernum-1].invite &
  1650. X                  Blocks[Playernum-1].pledge);
  1651. X          for(i=1; i<=Numraces(); i++)
  1652. X              if(isset(dummy, i) && i!=Playernum)
  1653. X              notify(i, buf);
  1654. X          } else
  1655. X            notify(who, buf);
  1656. X
  1657. X            notify(Playernum, "Request sent.\n");
  1658. X            break;
  1659. X        }
  1660. X    deductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
  1661. X}
  1662. X
  1663. Xsend_message(Playernum, APcount0, argn, args)
  1664. Xint Playernum;
  1665. Xint APcount0;
  1666. Xint argn;
  1667. Xchar args[MAXARGS][COMMANDSIZE];
  1668. X{
  1669. Xint who, i, j, to_block, dummy, APcount;
  1670. Xracetype *Race, *alien;
  1671. X
  1672. X    APcount = APcount0;
  1673. X    Num_races = Numraces();
  1674. X
  1675. Xto_block = 0;
  1676. Xif(!strncmp(args[1], "block", strlen(args[1]))) {
  1677. X    to_block = 1;
  1678. X    notify(Playernum, "Sending message to alliance block.\n");
  1679. X} else {
  1680. X    GetPlayer(args[1], &who, &alien);
  1681. X   if (who < 1 || who > Num_races ) {
  1682. X    sprintf(buf,"No such player.\n");
  1683. X        notify(Playernum, buf);
  1684. X    return;
  1685. X   }
  1686. XAPcount *= !alien->God;
  1687. Xfree(alien);
  1688. X}
  1689. X
  1690. X    switch(Dir[Playernum-1].level) {
  1691. X        case LEVEL_UNIV:
  1692. X            sprintf(buf, "You can't send messages from universal scope.\n");
  1693. X            notify(Playernum, buf);
  1694. X            return;
  1695. X            break;
  1696. X
  1697. X        case LEVEL_SHIP:
  1698. X            sprintf(buf, "You can't send messages from ship scope.\n");
  1699. X            notify(Playernum, buf);
  1700. X            return;
  1701. X            break;
  1702. X
  1703. X        default:
  1704. X            openstardata(&name_stardata);
  1705. X            free(Stars[Dir[Playernum-1].snum]);
  1706. X            getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
  1707. X            close_file(name_stardata);
  1708. X            if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount))
  1709. X                return;
  1710. X            break;
  1711. X            }
  1712. X
  1713. Xopenracedata(&name_racedata);
  1714. Xgetrace(name_racedata, &Race, Playernum); 
  1715. Xclose_file(name_racedata);
  1716. X
  1717. X            /* send the message */
  1718. X    sprintf(msg, "From %s [%d]: ", Race->name, Playernum);
  1719. X           
  1720. X/* put the message together */
  1721. X        for(j=2; j < argn; j++)    
  1722. X            {
  1723. X            sprintf(buf, "%s ", args[j]);
  1724. X            strcat(msg, buf);            
  1725. X            }
  1726. X/* post it */
  1727. X        sprintf(buf, "%s has sent you a telegram. Use `read' to read it.\n", Race->name);
  1728. X        if(to_block) {
  1729. X          dummy = (Blocks[Playernum-1].invite &
  1730. X                  Blocks[Playernum-1].pledge);
  1731. X          sprintf(buf, "%s [%d] sends a message to alliance block.\n",
  1732. X              Race->name, Playernum);
  1733. X          for(i=1; i<=Num_races; i++) {
  1734. X              if(isset(dummy, i) && i!=Playernum) {
  1735. X             notify(i, buf);
  1736. X                  push_message(Playernum, i, msg, TELEGRAM); 
  1737. X              }
  1738. X              push_message(TELEG_PLAYER_AUTO, i, buf, TRANSFER);
  1739. X          }
  1740. X          } else {
  1741. X          notify(who, buf);
  1742. X          push_message(Playernum, who, msg, TELEGRAM); 
  1743. X
  1744. X        openracedata(&name_racedata);
  1745. X          getrace(name_racedata, &alien, who);
  1746. X
  1747. X          sprintf(buf, "%s [%d] sends a message to %s [%d].\n",
  1748. X              Race->name, Playernum, alien->name, who);
  1749. X
  1750. X          for(i=1; i<=Num_races; i++)
  1751. X              push_message(TELEG_PLAYER_AUTO, i, buf, TRANSFER);
  1752. X
  1753. X          /* translation modifier increases */
  1754. X          alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+2, 100);
  1755. X          putrace(name_racedata, alien);    
  1756. X          close_file(name_racedata);
  1757. X          free(alien);
  1758. X          }
  1759. X
  1760. X        free(Race);
  1761. X        notify(Playernum, "Message sent.\n");
  1762. XdeductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
  1763. X}
  1764. X
  1765. Xread_messages(Playernum, APcount, argn, args)
  1766. Xint Playernum;
  1767. Xint APcount;
  1768. Xint argn;
  1769. Xchar args[MAXARGS][COMMANDSIZE];
  1770. X{
  1771. Xint i;
  1772. X  i = strlen(args[1]);
  1773. X
  1774. X    if(argn==1 || !strncmp("telegram", args[1], i))
  1775. X    teleg_read(Playernum, TELEGRAM);
  1776. X    else if(!strncmp("news", args[1], i)) {
  1777. X    notify(Playernum, CUTE_MESSAGE);
  1778. X    notify(Playernum, "\n----------           Politics        ----------\n");
  1779. X    teleg_read(Playernum, DECLARATION);
  1780. X    notify(Playernum, "\n----------          War Stories      ----------\n");
  1781. X    teleg_read(Playernum, COMBAT);
  1782. X    notify(Playernum, "\n----------     Wheelin' and Dealin'  ----------\n");
  1783. X    teleg_read(Playernum, TRANSFER);
  1784. X    notify(Playernum, "\n----------         Classifieds       ----------\n");
  1785. X    teleg_read(Playernum, ANNOUNCE);
  1786. X    } else
  1787. X    notify(Playernum, "Read what?\n");
  1788. X   }
  1789. X
  1790. X
  1791. Xannounce(Playernum, APcount, argn, args, broadcast)
  1792. Xint Playernum;
  1793. Xint APcount;
  1794. Xint argn;
  1795. Xchar args[MAXARGS][COMMANDSIZE];
  1796. Xint broadcast;
  1797. X{
  1798. Xint i, j;
  1799. Xracetype *r, *Race;
  1800. X
  1801. Xopenracedata(&name_racedata);
  1802. Xgetrace(name_racedata, &Race, Playernum); 
  1803. Xclose_file(name_racedata);
  1804. X
  1805. Xswitch(Dir[Playernum-1].level) {
  1806. X    case LEVEL_UNIV:
  1807. X        sprintf(buf, "You can't make announcements at universal scope.\n");
  1808. X            notify(Playernum, buf);
  1809. X        break;
  1810. X    default:
  1811. X        openstardata(&name_stardata);
  1812. X        free(Stars[Dir[Playernum-1].snum]);
  1813. X        getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
  1814. X        close_file(name_stardata);
  1815. X        if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
  1816. X            free(Race);
  1817. X            return;
  1818. X
  1819. X            }
  1820. X    if(!(!!isset(Stars[Dir[Playernum-1].snum]->inhabited, Playernum) || Race->God)) {
  1821. X            sprintf(buf, "You do not inhabit this system or have diety privileges.\n");
  1822. X            notify(Playernum, buf);
  1823. X            free(Race);
  1824. X            return;
  1825. X        }
  1826. X
  1827. Xif(!broadcast)
  1828. X    sprintf(msg, "%s : ", Race->name);
  1829. Xelse
  1830. X    sprintf(msg, "%s [%d] > ", Race->name, Playernum);
  1831. X
  1832. X    Num_races = Numraces();
  1833. X
  1834. X        for(j=1; j < argn; j++)    
  1835. X            {
  1836. X            sprintf(buf, "%s ", args[j]);
  1837. X            strcat(msg, buf);            
  1838. X            }
  1839. X            strcat(msg, "\n");
  1840. X
  1841. X    for(i=1; i<=Num_races; i++) 
  1842. X        if(i != Playernum) {
  1843. X        openracedata(&name_racedata);
  1844. X        getrace(name_racedata, &r, i); 
  1845. X        close_file(name_racedata);
  1846. X
  1847. X    if((broadcast && !r->gag) || (Dir[i-1].level != LEVEL_UNIV && (Dir[i-1].snum == Dir[Playernum-1].snum) 
  1848. X            &&  (!!isset(Stars[Dir[Playernum-1].snum]->inhabited, i) || Race->God)))
  1849. X        notify(i, msg);
  1850. X        free(r);
  1851. X        }
  1852. X
  1853. X        break;
  1854. X    }
  1855. X
  1856. X    deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
  1857. Xfree(Race);
  1858. X}
  1859. X
  1860. X
  1861. Xmotto(Playernum, APcount, argn, args)
  1862. Xint Playernum;
  1863. Xint APcount;
  1864. Xint argn;
  1865. Xchar args[MAXARGS][COMMANDSIZE];
  1866. X{ 
  1867. Xint i;
  1868. Xchar temp[128];
  1869. X
  1870. Xsprintf(buf, "%s", args[1]);
  1871. X        for(i=2; i < argn; i++)    
  1872. X            {
  1873. X            sprintf(temp, " %s", args[i]);
  1874. X            strcat(buf, temp);            
  1875. X            }
  1876. X
  1877. X    sprintf(Blocks[Playernum-1].motto, "%s", buf);
  1878. X    Putblock(Blocks);
  1879. X    notify(Playernum, "Done.\n");
  1880. X}
  1881. X
  1882. Xname(Playernum,APcount, argn,args)
  1883. Xint Playernum;
  1884. Xint APcount;
  1885. Xint argn;
  1886. Xchar args[MAXARGS][COMMANDSIZE];
  1887. X{
  1888. Xchar *ch;
  1889. Xregister int i, s, spaces;
  1890. Xboolean check=0;
  1891. Xshiptype *ship;
  1892. Xstartype *star;
  1893. Xplanettype *p;
  1894. Xchar string[1024];
  1895. Xchar temp[128];
  1896. Xracetype *Race;
  1897. X
  1898. Xname_stardata = NEUTRAL_FD;
  1899. X
  1900. Xif(!isalnum(args[2][0]) || argn < 3) {
  1901. X        notify(Playernum, "Illegal name format.\n");
  1902. X        return;
  1903. X        }
  1904. X
  1905. Xsprintf(buf, "%s", args[2]);
  1906. X        for(i=3; i < argn; i++)    
  1907. X            {
  1908. X            sprintf(temp, " %s", args[i]);
  1909. X            strcat(buf, temp);            
  1910. X            }
  1911. X
  1912. Xsprintf(string, "%s", buf);
  1913. X
  1914. X    i=strlen(args[0]);
  1915. X
  1916. X      /* make sure there are no ^'s or '/' in name, 
  1917. X        also make sure the name has at least 1 character in it */
  1918. X  ch = string;
  1919. X  spaces = 0;
  1920. X  while (*ch!='\0') {
  1921. X      check |= ((!isalnum(*ch) && !(*ch==' ')) || (*ch=='/') );
  1922. X      ch++;
  1923. X      if(*ch==' ') spaces++;
  1924. X    }
  1925. X
  1926. X    if(spaces==strlen(buf)) {    
  1927. X        notify(Playernum, "Illegal name.\n");
  1928. X        return;
  1929. X        }
  1930. X
  1931. X  if (strlen(buf) < 1 || check) {
  1932. X    sprintf(buf, "Illegal name %s.\n", check ? "form" : "length" );
  1933. X        notify(Playernum, buf);
  1934. X    return;
  1935. X  }
  1936. X
  1937. X        if (!strncmp(args[1],"ship",i)) {
  1938. X        if(Dir[Playernum-1].level == LEVEL_SHIP) {
  1939. X        openshdata(&name_shdata);
  1940. X        getship(name_shdata, &ship, Dir[Playernum-1].shipno);
  1941. X
  1942. X        sprintf(ship->name, "%s", buf);
  1943. X        putship(name_shdata, ship, Dir[Playernum-1].shipno);
  1944. X        close_file(name_shdata);
  1945. X            notify(Playernum, "Name set.\n");
  1946. X            free(ship);
  1947. X            return;
  1948. X        } else {
  1949. X            notify(Playernum, "You have to 'cs' to a ship to name it.\n");
  1950. X            return;
  1951. X        }
  1952. X        } else if (!strncmp(args[1],"class",i)) {
  1953. X        if(Dir[Playernum-1].level == LEVEL_SHIP) {
  1954. X        openshdata(&name_shdata);
  1955. X        getship(name_shdata, &ship, Dir[Playernum-1].shipno);
  1956. X        close_file(name_shdata);
  1957. X    if(ship->type != OTYPE_FACTORY) {
  1958. X        notify(Playernum, "You are not at a factory!\n");
  1959. X        free(ship);
  1960. X        return;
  1961. X        }
  1962. X    if(ship->on) {
  1963. X        notify(Playernum, "This factory is already on line.\n");
  1964. X        free(ship);
  1965. X        return;
  1966. X        }
  1967. X
  1968. X        sprintf(ship->class, "%s", buf);
  1969. X        openshdata(&name_shdata);
  1970. X        putship(name_shdata, ship, Dir[Playernum-1].shipno);
  1971. X        close_file(name_shdata);
  1972. X            notify(Playernum, "Class set.\n");
  1973. X            free(ship);
  1974. X            return;
  1975. X        } else {
  1976. X            notify(Playernum, "You have to 'cs' to a factory to name the ship class.\n");
  1977. X            return;
  1978. X        }
  1979. X        } else if (!strncmp(args[1], "block", i)) {
  1980. X/* name your alliance block */
  1981. X    sprintf(Blocks[Playernum-1].name, "%s", buf);
  1982. X    Putblock(Blocks);
  1983. X    notify(Playernum, "Done.\n");
  1984. X    }else if (!strncmp(args[1],"star",i)) {
  1985. X
  1986. X        if(Dir[Playernum-1].level == LEVEL_STAR) {
  1987. X            openracedata(&name_racedata);
  1988. X            getrace(name_racedata, &Race, Playernum);
  1989. X            close_file(name_racedata);
  1990. X        if (!Race->God) {
  1991. X                notify(Playernum, "Only dieties may name a star.\n");
  1992. X            free(Race);
  1993. X            return;
  1994. X                    }
  1995. X            free(Race);
  1996. X/* got to get all stars, to stop cheaters */
  1997. X            openstardata(&name_stardata);
  1998. X            for (s=0; s<Sdata.numstars; s++) {
  1999. X                free(Stars[s]);
  2000. X                getstar(name_stardata, &Stars[s], s);
  2001. X                }
  2002. X            close_file(name_stardata);
  2003. X
  2004. X            for(s=0; s<Sdata.numstars; s++) {
  2005. X                if(s!=Dir[Playernum-1].snum)
  2006. X                    if(!strncmp(Stars[s]->name, buf, strlen(Stars[s]->name)))
  2007. X                        {
  2008. X            notify(Playernum, 
  2009. X                "Thats not fair trying to name a star that! 50 APs deducted for cheating!!!\n");
  2010. X                        return;
  2011. X                        }
  2012. X                }
  2013. X
  2014. X
  2015. X/* check to see if there are any other stars with this name - stops cheaters */
  2016. X    
  2017. X
  2018. Xsprintf(Stars[Dir[Playernum-1].snum]->name, "%s", buf);
  2019. X            openstardata(&name_stardata);
  2020. X            putstar(name_stardata, Stars[Dir[Playernum-1].snum], 
  2021. X            Dir[Playernum-1].snum);
  2022. X        close_file(name_stardata);
  2023. X        } else {
  2024. X            notify(Playernum, "You have to 'cs' to a star to name it.\n");
  2025. X            return;
  2026. X        }
  2027. X        } else if (!strncmp(args[1],"planet",i)) {
  2028. X        if(Dir[Playernum-1].level == LEVEL_PLAN) {
  2029. X                free(Stars[Dir[Playernum-1].snum]);
  2030. X                openstardata(&name_stardata);
  2031. X            getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
  2032. X            close_file(name_stardata);
  2033. X
  2034. X            openracedata(&name_racedata);
  2035. X            getrace(name_racedata, &Race, Playernum);
  2036. X            close_file(name_racedata);
  2037. X
  2038. X            if (!Race->God && !MostAPs(Playernum,Stars[Dir[Playernum-1].snum])) {
  2039. X                  notify(Playernum,"You don't have the most AP's in that system.\n");
  2040. X                  free(Race);
  2041. X                  return;
  2042. X                }
  2043. X                free(Race);
  2044. X
  2045. X        for(s=0; s<Stars[Dir[Playernum-1].snum]->numplanets; s++)
  2046. X            if(!strncmp(Stars[Dir[Playernum-1].snum]->pnames[s], buf, 
  2047. X                strlen(Stars[Dir[Playernum-1].snum]->pnames[s])))
  2048. X                {
  2049. X                notify(Playernum, 
  2050. X                    "Sorry, that name is already taken. 50 APs deducted for cheating!!!\n");
  2051. X                return;
  2052. X                }
  2053. X
  2054. X
  2055. Xsprintf(Stars[Dir[Playernum-1].snum]->pnames[Dir[Playernum-1].pnum], "%s", buf);
  2056. X            openstardata(&name_stardata);
  2057. X            putstar(name_stardata, Stars[Dir[Playernum-1].snum],  Dir[Playernum-1].snum);
  2058. X            close_file(name_stardata);
  2059. X        deductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
  2060. X
  2061. X        } else {
  2062. X            notify(Playernum, "You have to 'cs' to a planet to name it.\n");
  2063. X            return;
  2064. X        }
  2065. X        } else if (!strncmp(args[1],"race",i)) {
  2066. X        openracedata(&name_racedata);
  2067. X        getrace(name_racedata, &Race, Playernum);
  2068. X        sprintf(Race->name, "%s", buf);
  2069. X        putrace(name_racedata, Race);
  2070. X        close_file(name_racedata);
  2071. X        free(Race);
  2072. X    } else {
  2073. X        notify(Playernum, "I don't know what you mean.\n");
  2074. X        return;
  2075. X    }    
  2076. X
  2077. X}
  2078. X
  2079. X
  2080. Xint MostAPs(Playernum,s)
  2081. Xint Playernum;
  2082. Xstartype *s;
  2083. X{
  2084. X register int i,t = 0;
  2085. X
  2086. X  for (i=0; i<MAXPLAYERS; i++)
  2087. X     if (s->AP[i] >= t)
  2088. X      t = s->AP[i];
  2089. X
  2090. X  return (s->AP[Playernum-1] == t);
  2091. X
  2092. X}
  2093. X
  2094. X
  2095. END_OF_FILE
  2096. if test 17264 -ne `wc -c <'server/name.c'`; then
  2097.     echo shar: \"'server/name.c'\" unpacked with wrong size!
  2098. fi
  2099. # end of 'server/name.c'
  2100. echo shar: End of archive 6 \(of 9\).
  2101. cp /dev/null ark6isdone
  2102. MISSING=""
  2103. for I in 1 2 3 4 5 6 7 8 9 ; do
  2104.     if test ! -f ark${I}isdone ; then
  2105.     MISSING="${MISSING} ${I}"
  2106.     fi
  2107. done
  2108. if test "${MISSING}" = "" ; then
  2109.     echo You have unpacked all 9 archives.
  2110.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2111. else
  2112.     echo You still need to unpack the following archives:
  2113.     echo "        " ${MISSING}
  2114. fi
  2115. ##  End of shell archive.
  2116. exit 0
  2117.